import React, { useState, useEffect } from "react";
import {
  Form,
  Input,
  Button,
  Select,
  Col,
  Breadcrumb,
  DatePicker,
  Space,
  Row,
  Radio,
} from "antd";
import axios from "axios";

const XinZengBingRen = (props) => {
  let defaultValue = { xingBie: "1" };
  const { Option } = Select;

  const [from, setFrom] = useState([]);
  const [form1] = Form.useForm();

  const getdata = () => {
    let obj = JSON.parse(sessionStorage.getItem("record"));
    console.log(obj);
    form1.setFieldsValue(obj);
    console.log(form1);
  };

  useEffect(() => {
    getdata();
    // eslint-disable-next-line
  }, []);
  // 返回上一页
  const ret = () => {
    props.history.go(-1);
  };

  function handleChange(value) {
    console.log(`selected ${value}`);
  }

  function onChange(date, dateString) {
    // console.log(date, dateString);
  }

  return (
    <div>
      {" "}
      {/* 表头 */}{" "}
      <Breadcrumb
        style={{
          marginBottom: 24,
        }}
      >
        <Breadcrumb.Item> 病人入院信息 </Breadcrumb.Item>{" "}
        <Breadcrumb.Item> 新增患者 </Breadcrumb.Item>{" "}
      </Breadcrumb>{" "}
      {/* 设定区域 */}{" "}
      <div
        className="site-layout-background huan"
        style={{
          padding: 24,
          margin: 12,
          minHeight: 300,
          textAlign: "center",
        }}
      >
        <h1
          style={{
            fontSize: 20,
          }}
        >
          <b> 新增患者 </b>
        </h1>{" "}
        <Form form={form1}>
          {" "}
          {/* // 第一行  */}{" "}
          <Row>
            {" "}
            {/* 第一列 */}{" "}
            <Col span={6} offset={2}>
              <Form.Item
                label="姓名"
                name="xingMing"
                initialValue={form1.xingMing}
                rules={[
                  {
                    required: true,
                    message: "请输入你的姓名",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="身份证号"
                name="shenFenZhengHao"
                initialValue={from.shenFenZhengHao}
                rules={[
                  {
                    required: true,
                    message: "请输入你的身份证号",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="性别"
                name="xingBie"
                initialValue={form1.xingBie}
                rules={[
                  {
                    required: true,
                    message: "请选择你的性别",
                  },
                ]}
              >
                <Select onChange={handleChange}>
                  <Option value="1"> 男 </Option>
                  <Option value="2"> 女 </Option>
                </Select>{" "}
              </Form.Item>{" "}
            </Col>{" "}
          </Row>{" "}
          {/* //第二行 */}{" "}
          <Row>
            {" "}
            {/* 第一列 */}{" "}
            <Col span={6} offset={2}>
              <Form.Item
                label="住址"
                name="zhuZhi"
                initialValue={form1.zhuZhi}
                rules={[
                  {
                    required: true,
                    message: "请输入你的住址",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="医疗证号"
                name="yiLiaoZheng"
                initialValue={form1.yiLiaoZhengHao}
                rules={[
                  {
                    required: true,
                    message: "请输入你的医疗证号",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="出生日期"
                name="chuShegRiqi"
                rules={[
                  {
                    required: true,
                    message: "请选择你的出生日期",
                  },
                ]}
              >
                <Space direction="vertical">
                  <DatePicker onChange={onChange} />{" "}
                </Space>{" "}
              </Form.Item>{" "}
            </Col>{" "}
          </Row>{" "}
          {/* 第三行 */}{" "}
          <Row>
            <Col span={6} offset={2}>
              <Form.Item
                label="关系"
                initialValue={form1.guanXi}
                name="guanXi"
                rules={[
                  {
                    required: true,
                    message: "请输入你的关系",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="疾病诊断"
                name="jiBingZhenDuan"
                initialValue={form1.jiBingZhenDuan}
                rules={[
                  {
                    required: true,
                    message: "请输入你的疾病诊断",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="入院时间"
                name="1"
                rules={[
                  {
                    required: true,
                    message: "请选择你的入院时间",
                  },
                ]}
              >
                <Space direction="vertical">
                  <DatePicker onChange={onChange} />{" "}
                </Space>{" "}
              </Form.Item>{" "}
            </Col>{" "}
          </Row>{" "}
          {/* 第四行 */}{" "}
          <Row>
            <Col span={6} offset={2}>
              <Form.Item
                label="电话"
                name="lianXiRenDianHua"
                initialValue={form1.lianXiRenDianHua}
                rules={[
                  {
                    required: true,
                    message: "请输入你的电话号码",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="记账方式"
                name="jieZhangFangShi"
                initialValue={form1.jieZhangFangShi}
                rules={[
                  {
                    required: true,
                    message: "请选择你的记账方式",
                  },
                ]}
              >
                <Select onChange={handleChange}>
                  <Option value="F"> F - 现金结算 </Option>{" "}
                  <Option value="G"> G - 支票结算 </Option>{" "}
                  <Option value="H"> H - 外币结算 </Option>{" "}
                  <Option value="L"> L - 转账结算 </Option>{" "}
                  <Option value="E"> E - 自费记账 </Option>{" "}
                </Select>{" "}
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="费别"
                name="1"
                rules={[
                  {
                    required: true,
                    message: "请选择费别方式",
                  },
                ]}
              >
                <Select onChange={handleChange}>
                  <Option value="A"> A - 特约记账 </Option>{" "}
                  <Option value="B"> B - 公费记账 </Option>{" "}
                  <Option value="C"> C - 保险记账 </Option>{" "}
                  <Option value="D"> D - 本校记账 </Option>{" "}
                  <Option value="E"> E - 自费记账 </Option>{" "}
                </Select>{" "}
              </Form.Item>{" "}
            </Col>{" "}
          </Row>{" "}
          {/* 第五行 */}{" "}
          <Row>
            <Col span={6} offset={2}>
              <Form.Item
                label="科别"
                name="keBie"
                initialValue={form1.keBie}
                rules={[
                  {
                    required: true,
                    message: "请输入你的科别",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="ICD9编码"
                name="icd9BianMa"
                initialValue={form1.icd9BianMa}
                rules={[
                  {
                    required: true,
                    message: "请输入你的ICD9编码",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="预交款"
                name="yuJiaoKuan"
                initialValue={form1.yuJiaoKuan}
                rules={[
                  {
                    required: true,
                    message: "请输入你的预交款",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
          </Row>{" "}
          {/* 第六行 */}{" "}
          <Row>
            <Col span={6} offset={2}>
              <Form.Item
                label="床号"
                name="chuangHao"
                initialValue={form1.chuangHao}
                rules={[
                  {
                    required: true,
                    message: "请输入你的床号",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="婚姻"
                name="1"
                rules={[
                  {
                    required: true,
                    message: "请选择你的婚姻状况",
                  },
                ]}
              >
                <Radio.Group onChange={onChange}>
                  <Radio value={1}> 已婚 </Radio>{" "}
                  <Radio value={2}> 未婚 </Radio>{" "}
                </Radio.Group>{" "}
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="籍贯"
                name="jiGuan"
                initialValue={form1.jiGuan}
                rules={[
                  {
                    required: true,
                    message: "请输入你的籍贯",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
          </Row>{" "}
          {/* 第七行 */}{" "}
          <Row>
            <Col span={6} offset={2}>
              <Form.Item
                label="职业"
                name="zhiYe"
                initialValue={form1.zhiYe}
                rules={[
                  {
                    required: true,
                    message: "请输入你的职业",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="工作单位"
                initialValue={form1.gongZuoDanWei}
                name="gongZuoDanWei"
                rules={[
                  {
                    required: true,
                    message: "请输入你的工作单位",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="职称"
                name="zhiCheng"
                initialValue={form1.zhiCheng}
                rules={[
                  {
                    required: true,
                    message: "请输入你的职称",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
          </Row>{" "}
          {/* 第八行 */}{" "}
          <Row>
            <Col span={6} offset={2}>
              <Form.Item
                label="国籍"
                name="guoJi"
                initialValue={form1.guoJi}
                rules={[
                  {
                    required: true,
                    message: "请输入你的国籍",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/*的第二列  */}{" "}
            <Col span={6} offset={1}>
              <Form.Item
                label="联系人"
                name="lianXiRen"
                initialValue={form1.lianXiRen}
                rules={[
                  {
                    required: true,
                    message: "请输入你的联系人",
                  },
                ]}
              >
                <Input />
              </Form.Item>{" "}
            </Col>{" "}
            {/* 第三列 */}{" "}
            {/* <Col span={6} offset={1}>                  
                              <Form.Item                       
                                label="职称"
                                name="zhicheng"
                                rules={[{ required: true, message: '请输入你的住址' }]}
                              >
                             <Input />
                              </Form.Item> 
                   </Col>  */}{" "}
          </Row>{" "}
        </Form>{" "}
      </div>{" "}
      <div
        className="site-layout-background huan"
        style={{
          padding: 24,
          margin: 12,
          minHeight: 30,
          textAlign: "center",
        }}
      >
        <Button
          type="primary"
          style={{
            marginRight: 30,
            width: 100,
            height: 40,
          }}
        >
          新增{" "}
        </Button>{" "}
        <Button
          style={{
            backgroundColor: "#40FF00",
            width: 100,
            height: 40,
          }}
          onClick={ret}
        >
          返回{" "}
        </Button>{" "}
      </div>{" "}
    </div>
  );
};

export default XinZengBingRen;
